//
//  ModifyItemView.m
//  HpnotiqCustomize
//
//  Created by Harmandeep Singh on 09/06/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ModifyItemView.h"
#import <QuartzCore/QuartzCore.h>

#define degreesToRadians(x) (M_PI * x / 180.0)







@implementation ModifyItemView

@synthesize mIsBeingMoved;
@synthesize mScaleTransformValue;
@synthesize mRotationTransformValue;


- (id)initWithView:(UIView *)view andFrame:(CGRect)frame
{
    self = [super initWithFrame:CGRectMake(frame.origin.x,
                                           frame.origin.y,
                                           view.frame.size.width,
                                           view.frame.size.height)];
    if(self) 
    {
        // Initialization code
        
        mMainView = [view retain];
        mMainView.frame = CGRectMake(0,
                                     0,
                                     view.frame.size.width,
                                     view.frame.size.height);
        [self addSubview:mMainView];
        
        mScaleTransformValue = 1.0;
        mRotationTransformValue = 0.0;
        
        self.layer.borderColor = [UIColor yellowColor].CGColor;
    }
    return self;
}

- (void)dealloc {
    
    [mMainView release];
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/



- (void)makeScaleTransformToValue:(CGFloat)floatValue
{
    mScaleTransformValue = floatValue;
    
    CGAffineTransform scaleTransform = CGAffineTransformMakeScale(mScaleTransformValue, mScaleTransformValue);
    CGAffineTransform rotateTransform = CGAffineTransformMakeRotation(degreesToRadians(mRotationTransformValue));
    self.transform = CGAffineTransformConcat(scaleTransform, rotateTransform);
}


- (void)makeScaleRotationToValue:(CGFloat)floatValue
{
    mRotationTransformValue = floatValue;
    
    CGAffineTransform scaleTransform = CGAffineTransformMakeScale(mScaleTransformValue, mScaleTransformValue);
    CGAffineTransform rotateTransform = CGAffineTransformMakeRotation(degreesToRadians(mRotationTransformValue));
    self.transform = CGAffineTransformConcat(scaleTransform, rotateTransform);
}

@end
